<?php
/**
 * User: chenjin
 * Date: 2022/1/11
 * Time: 19:13
 */

namespace yi\web;

class UrlManager extends \yi\base\Component
{
    public $routeParam = 'r';

    public $enablePrettyUrl;//是否启用简洁的url


    /**
     * @param Request $request
     * @return array|false
     */
    public function parseRequest(Request $request)
    {
        if ($this->enablePrettyUrl) {
            //路由逻辑不接
            $pathInfo = $request->getPathInfo();
            return [$pathInfo, []];
        }

        $route = $request->getQueryParam($this->routeParam, '');
        if (is_array($route)) {
            $route = '';
        }

        return [(string)$route, []];
    }
}
